#!/bin/bash
##################################################################
## function:chean_track  clean  track to clean_track table
## eg：bash chean_track.sh 20150505
## author: shx
## createdate: 20150908 
## version:     
################################################################## 
. /home/hadoop/shx/baseUtil.sh


if [[ ! -n "$1" ]] && [[ ! -n "$2" ]] ;then
	HISTORYDATE=`date -d '-1 days'  +%Y%m%d`
	HOUR=`date -d '-1 hours' +%H`
else
	HISTORYDATE=$1
	HOUR=$2
fi


echo `date`"==========chean_track start===============" 
/usr/local/cloud/hive/bin/hive -e  " 
USE qyer;
ALTER TABLE clean_track DROP IF NOT EXISTS PARTITION (logdate='$HISTORYDATE');
ALTER TABLE clean_track ADD IF NOT EXISTS PARTITION (logdate='$HISTORYDATE') LOCATION '/flume/clean/track/$HISTORYDATE';
"

/usr/local/cloud/hadoop/bin/hadoop  jar /home/hadoop/shx/clean_track/qyer_clean.jar /flume/original/track/$HISTORYDATE/*/* /flume/clean/track/$HISTORYDATE /flume/dict/ugc_type/20150915 /flume/dict/citycountrylist/20150915
if [ $? -eq 0 ]
  then
  	echo `date`"=============== chean_track is ok  end===============" 
else
  	echo `date`"================chean_track is error end !================" 
  	mailSend "143 :chean_track is error end !"
fi








